﻿using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Reporting.WinForms;

namespace RDLCPrinter

{

    /// <summary>

    /// Interaction logic for ReportViewer.xaml

    /// </summary>

    public partial class ReportViewer : UserControl

    {

        public ReportViewer()

        {

            InitializeComponent();

        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {          
            DataTable dt2 = new DataTable();
            dt2.Columns.Add(new DataColumn("warehouseKeeper", typeof(string)));
            dt2.Columns.Add(new DataColumn("outStockTime", typeof(string)));
            dt2.Columns.Add(new DataColumn("transporter", typeof(string)));
            dt2.Columns.Add(new DataColumn("place", typeof(string)));
            
            DataRow dr2 = dt2.NewRow();
            dr2["warehouseKeeper"] = "模拟仓管";
            dr2["outStockTime"] = DateTime.Now.ToString();
            dr2["transporter"] = "黄槟";
            dr2["place"] = "泉州师范学院软件学院";
            dt2.Rows.Add(dr2);

            ReportDataSource reportDataSource2 = new ReportDataSource();

            reportDataSource2.Name = "DataSet2";
            reportDataSource2.Value = dt2;
            reportViewer1.LocalReport.DataSources.Add(reportDataSource2);






            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("goods_Id", typeof(string)));
            dt.Columns.Add(new DataColumn("goods_Name", typeof(string)));
            dt.Columns.Add(new DataColumn("warehouse_Id", typeof(string)));
            dt.Columns.Add(new DataColumn("date_Of_Manufacture", typeof(string)));
            dt.Columns.Add(new DataColumn("shelf_Life", typeof(string)));

            DataRow dr = dt.NewRow();
            for (int i = 0; i < 10; i++)
            {
                dt.Rows.Add(new string[] { ("模拟id" + i).ToString(), ("模拟货物名" + i).ToString(), ("模拟仓库"+i).ToString(),
                    DateTime.Now.ToString(),"模拟保质期" + i.ToString()});
            } 

            ReportDataSource reportDataSource = new ReportDataSource();
            reportDataSource.Name = "DataSet1";
            reportDataSource.Value = dt;
            reportViewer1.LocalReport.DataSources.Add(reportDataSource);


            reportViewer1.LocalReport.ReportPath = @"C:\Users\黄燕槟\Desktop\print\RDLC\OutOfStock.rdlc";//"D:\\Documents\\GitHub\\DEMO\\RDLC\\RDLC\\CustomerReport.rdlc"; 
            //刷新
            reportViewer1.RefreshReport();

        }
        private void reportViewer_RenderingComplete(object sender, Microsoft.Reporting.WinForms.RenderingCompleteEventArgs e)

        {



        }

    }

}
